{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python_defaultSpec_1600600171175",
   "display_name": "Python 3.8.2 64-bit"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "from pandas import concat"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pdb_profiling.fetcher.webfetch import UnsyncFetch\n",
    "from pdb_profiling.utils import DisplayPDB\n",
    "from pdb_profiling.processers.pdbe.api import *\n",
    "from pdb_profiling.processers.pdbe.record import *\n",
    "\n",
    "ProcessPDBe.use_existing = True  # Use Existing Handled PDBe API Results (e.g. tsv format results)\n",
    "ProcessPDBe.init_logger()  # Init PDBe API Logger\n",
    "UnsyncFetch.use_existing = True  # Use Existing API Results (e.g. json format results downloaded from web)\n",
    "UnsyncFetch.init_setting(ProcessPDBe.logger)  # Init WebFetcher's Logger (pass it with PDBe API Logger)\n",
    "PDBeModelServer.init_logger(logger=ProcessPDBe.logger)  # Init ModelServer API's Logger (pass it with PDBe API Logger)\n",
    "PDBArchive.init_logger(logger=ProcessPDBe.logger)  # Init PDBArchive API's Logger (pass it with PDBe API Logger)\n",
    "PDB.set_web_semaphore(30)  # Set WebFetcher's Semaphore\n",
    "PDB.set_folder('../test/demo')  # Set Folder that store downloaded and handled files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "demo_pdbs = ('1a04', '2xya', '3hl5', '4hhr', '5tm3')\n",
    "demo_pdb_obs:List[PDB] = [PDB(pdb_id) for pdb_id in demo_pdbs]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "CPU times: user 297 ms, sys: 156 ms, total: 453 ms\nWall time: 14.1 s\n"
    }
   ],
   "source": [
    "%time assert all(pdb_ob.status['status_code'] == 'REL' for pdb_ob in demo_pdb_obs), \"Unexcepted Cases\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "CPU times: user 0 ns, sys: 0 ns, total: 0 ns\nWall time: 20.3 µs\n"
    },
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "{'related_structures': [],\n 'split_entry': [],\n 'title': 'THE STRUCTURE OF THE NITRATE/NITRITE RESPONSE REGULATOR PROTEIN NARL IN THE MONOCLINIC C2 CRYSTAL FORM',\n 'release_date': '19980318',\n 'experimental_method': ['X-ray diffraction'],\n 'experimental_method_class': ['x-ray'],\n 'revision_date': '20110713',\n 'entry_authors': ['Baikalov, I.',\n  'Schroder, I.',\n  'Kaczor-Grzeskowiak, M.',\n  'Cascio, D.',\n  'Gunsalus, R.P.',\n  'Dickerson, R.E.'],\n 'deposition_site': None,\n 'number_of_entities': {'polypeptide': 1,\n  'dna': 0,\n  'ligand': 0,\n  'dna/rna': 0,\n  'rna': 0,\n  'sugar': 0,\n  'water': 1,\n  'other': 0,\n  'carbohydrate_polymer': 0},\n 'processing_site': None,\n 'deposition_date': '19971208',\n 'assemblies': [{'assembly_id': '1',\n   'form': 'homo',\n   'preferred': True,\n   'name': 'monomer'},\n  {'assembly_id': '2', 'form': 'homo', 'preferred': False, 'name': 'monomer'}]}"
     },
     "metadata": {},
     "execution_count": 5
    }
   ],
   "source": [
    "%time demo_pdb_obs[0].summary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "<PDB 1a04>"
     },
     "metadata": {},
     "execution_count": 6
    }
   ],
   "source": [
    "demo_pdb_obs[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stderr",
     "text": "100%|██████████| 5/5 [00:07<00:00,  1.55s/it]\n"
    }
   ],
   "source": [
    "res_dfs = UnsyncFetch.unsync_tasks([pdb_ob.fetch_from_web_api('api/pdb/entry/residue_listing/', PDB.to_dataframe) for pdb_ob in demo_pdb_obs]).result()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "     author_insertion_code  author_residue_number multiple_conformers  \\\n0                                             298                 NaN   \n1                                             299                 NaN   \n2                                             300                 NaN   \n3                                             301                 NaN   \n4                                             302                 NaN   \n...                    ...                    ...                 ...   \n2014                                          714                 NaN   \n2015                                          715                 NaN   \n2016                                          716                 NaN   \n2017                                          718                 NaN   \n2018                                          717                 NaN   \n\n      observed_ratio residue_name  residue_number chain_id struct_asym_id  \\\n0                0.0          ILE               1        A              A   \n1                0.0          LYS               2        A              A   \n2                0.0          ARG               3        A              A   \n3                0.0          SER               4        A              A   \n4                0.0          LYS               5        A              A   \n...              ...          ...             ...      ...            ...   \n2014             1.0          BNG               1        A              O   \n2015             1.0          P6G               1        A              P   \n2016             1.0          PGE               1        A              Q   \n2017             1.0          PGE               1        A              S   \n2018             1.0          PGE               1        A              R   \n\n     entity_id pdb_id  \n0            1   5tm3  \n1            1   5tm3  \n2            1   5tm3  \n3            1   5tm3  \n4            1   5tm3  \n...        ...    ...  \n2014         6   4hhr  \n2015         7   4hhr  \n2016         8   4hhr  \n2017         8   4hhr  \n2018         8   4hhr  \n\n[2019 rows x 10 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>author_insertion_code</th>\n      <th>author_residue_number</th>\n      <th>multiple_conformers</th>\n      <th>observed_ratio</th>\n      <th>residue_name</th>\n      <th>residue_number</th>\n      <th>chain_id</th>\n      <th>struct_asym_id</th>\n      <th>entity_id</th>\n      <th>pdb_id</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td></td>\n      <td>298</td>\n      <td>NaN</td>\n      <td>0.0</td>\n      <td>ILE</td>\n      <td>1</td>\n      <td>A</td>\n      <td>A</td>\n      <td>1</td>\n      <td>5tm3</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td></td>\n      <td>299</td>\n      <td>NaN</td>\n      <td>0.0</td>\n      <td>LYS</td>\n      <td>2</td>\n      <td>A</td>\n      <td>A</td>\n      <td>1</td>\n      <td>5tm3</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td></td>\n      <td>300</td>\n      <td>NaN</td>\n      <td>0.0</td>\n      <td>ARG</td>\n      <td>3</td>\n      <td>A</td>\n      <td>A</td>\n      <td>1</td>\n      <td>5tm3</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td></td>\n      <td>301</td>\n      <td>NaN</td>\n      <td>0.0</td>\n      <td>SER</td>\n      <td>4</td>\n      <td>A</td>\n      <td>A</td>\n      <td>1</td>\n      <td>5tm3</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td></td>\n      <td>302</td>\n      <td>NaN</td>\n      <td>0.0</td>\n      <td>LYS</td>\n      <td>5</td>\n      <td>A</td>\n      <td>A</td>\n      <td>1</td>\n      <td>5tm3</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>2014</th>\n      <td></td>\n      <td>714</td>\n      <td>NaN</td>\n      <td>1.0</td>\n      <td>BNG</td>\n      <td>1</td>\n      <td>A</td>\n      <td>O</td>\n      <td>6</td>\n      <td>4hhr</td>\n    </tr>\n    <tr>\n      <th>2015</th>\n      <td></td>\n      <td>715</td>\n      <td>NaN</td>\n      <td>1.0</td>\n      <td>P6G</td>\n      <td>1</td>\n      <td>A</td>\n      <td>P</td>\n      <td>7</td>\n      <td>4hhr</td>\n    </tr>\n    <tr>\n      <th>2016</th>\n      <td></td>\n      <td>716</td>\n      <td>NaN</td>\n      <td>1.0</td>\n      <td>PGE</td>\n      <td>1</td>\n      <td>A</td>\n      <td>Q</td>\n      <td>8</td>\n      <td>4hhr</td>\n    </tr>\n    <tr>\n      <th>2017</th>\n      <td></td>\n      <td>718</td>\n      <td>NaN</td>\n      <td>1.0</td>\n      <td>PGE</td>\n      <td>1</td>\n      <td>A</td>\n      <td>S</td>\n      <td>8</td>\n      <td>4hhr</td>\n    </tr>\n    <tr>\n      <th>2018</th>\n      <td></td>\n      <td>717</td>\n      <td>NaN</td>\n      <td>1.0</td>\n      <td>PGE</td>\n      <td>1</td>\n      <td>A</td>\n      <td>R</td>\n      <td>8</td>\n      <td>4hhr</td>\n    </tr>\n  </tbody>\n</table>\n<p>2019 rows × 10 columns</p>\n</div>"
     },
     "metadata": {},
     "execution_count": 8
    }
   ],
   "source": [
    "concat(res_dfs, sort=False, ignore_index=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stderr",
     "text": "100%|██████████| 5/5 [00:07<00:00,  1.55s/it]\n"
    }
   ],
   "source": [
    "async def pipe_fetch_assg(pdb_ob: PDB):\n",
    "    return await pdb_ob.fetch_from_modelServer_api(\n",
    "        'atoms', \n",
    "        data_collection=await pdb_ob.pipe_assg_data_collection(),\n",
    "        then_func=PDB.to_assg_oper_df)\n",
    "\n",
    "res_dfs = UnsyncFetch.unsync_tasks([pipe_fetch_assg(pdb_ob) for pdb_ob in demo_pdb_obs]).result()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "    assembly_id struct_asym_id oper_expression  model_id  asym_id_rank  \\\n0             1              A           [\"1\"]         1             1   \n1             1              C           [\"1\"]         1             1   \n2             1              D           [\"1\"]         1             1   \n3             1              G           [\"1\"]         1             1   \n4             2              B           [\"1\"]         1             1   \n5             2              E           [\"1\"]         1             1   \n6             2              F           [\"1\"]         1             1   \n7             2              H           [\"1\"]         1             1   \n8             1              A           [\"1\"]         1             1   \n9             1              C           [\"1\"]         1             1   \n10            2              B           [\"1\"]         1             1   \n11            2              D           [\"1\"]         1             1   \n12            1              A           [\"1\"]         1             1   \n13            1              B           [\"1\"]         1             1   \n14            1              C           [\"1\"]         1             1   \n15            1              D           [\"1\"]         1             1   \n16            1              E           [\"1\"]         1             1   \n17            1              F           [\"1\"]         1             1   \n18            1              G           [\"1\"]         1             1   \n19            1              H           [\"1\"]         1             1   \n20            1              I           [\"1\"]         1             1   \n21            1              J           [\"1\"]         1             1   \n22            1              K           [\"1\"]         1             1   \n23            1              L           [\"1\"]         1             1   \n24            1              M           [\"1\"]         1             1   \n25            1              N           [\"1\"]         1             1   \n26            1              O           [\"1\"]         1             1   \n27            1              P           [\"1\"]         1             1   \n28            1              Q           [\"1\"]         1             1   \n29            1              R           [\"1\"]         1             1   \n30            1              S           [\"1\"]         1             1   \n31            1              T           [\"1\"]         1             1   \n32            1              A           [\"1\"]         1             1   \n33            1              B           [\"1\"]         1             1   \n34            1              C           [\"1\"]         1             1   \n35            1              A           [\"1\"]         1             1   \n36            1              B           [\"1\"]         1             1   \n37            1              C           [\"1\"]         1             1   \n38            1              D           [\"1\"]         1             1   \n39            1              E           [\"1\"]         1             1   \n40            1              F           [\"1\"]         1             1   \n41            1              G           [\"1\"]         1             1   \n42            1              H           [\"1\"]         1             1   \n\n   symmetry_operation  \n0           [\"x,y,z\"]  \n1           [\"x,y,z\"]  \n2           [\"x,y,z\"]  \n3           [\"x,y,z\"]  \n4           [\"x,y,z\"]  \n5           [\"x,y,z\"]  \n6           [\"x,y,z\"]  \n7           [\"x,y,z\"]  \n8           [\"x,y,z\"]  \n9           [\"x,y,z\"]  \n10          [\"x,y,z\"]  \n11          [\"x,y,z\"]  \n12          [\"x,y,z\"]  \n13          [\"x,y,z\"]  \n14          [\"x,y,z\"]  \n15          [\"x,y,z\"]  \n16          [\"x,y,z\"]  \n17          [\"x,y,z\"]  \n18          [\"x,y,z\"]  \n19          [\"x,y,z\"]  \n20          [\"x,y,z\"]  \n21          [\"x,y,z\"]  \n22          [\"x,y,z\"]  \n23          [\"x,y,z\"]  \n24          [\"x,y,z\"]  \n25          [\"x,y,z\"]  \n26          [\"x,y,z\"]  \n27          [\"x,y,z\"]  \n28          [\"x,y,z\"]  \n29          [\"x,y,z\"]  \n30          [\"x,y,z\"]  \n31          [\"x,y,z\"]  \n32          [\"x,y,z\"]  \n33          [\"x,y,z\"]  \n34          [\"x,y,z\"]  \n35          [\"x,y,z\"]  \n36          [\"x,y,z\"]  \n37          [\"x,y,z\"]  \n38          [\"x,y,z\"]  \n39          [\"x,y,z\"]  \n40          [\"x,y,z\"]  \n41          [\"x,y,z\"]  \n42          [\"x,y,z\"]  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>assembly_id</th>\n      <th>struct_asym_id</th>\n      <th>oper_expression</th>\n      <th>model_id</th>\n      <th>asym_id_rank</th>\n      <th>symmetry_operation</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>1</td>\n      <td>A</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>1</td>\n      <td>C</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>1</td>\n      <td>D</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>1</td>\n      <td>G</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2</td>\n      <td>B</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>2</td>\n      <td>E</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>2</td>\n      <td>F</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>2</td>\n      <td>H</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>1</td>\n      <td>A</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>1</td>\n      <td>C</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>2</td>\n      <td>B</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>2</td>\n      <td>D</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>12</th>\n      <td>1</td>\n      <td>A</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>13</th>\n      <td>1</td>\n      <td>B</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>14</th>\n      <td>1</td>\n      <td>C</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>15</th>\n      <td>1</td>\n      <td>D</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>16</th>\n      <td>1</td>\n      <td>E</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>17</th>\n      <td>1</td>\n      <td>F</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>18</th>\n      <td>1</td>\n      <td>G</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>19</th>\n      <td>1</td>\n      <td>H</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>20</th>\n      <td>1</td>\n      <td>I</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>21</th>\n      <td>1</td>\n      <td>J</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>22</th>\n      <td>1</td>\n      <td>K</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>23</th>\n      <td>1</td>\n      <td>L</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>24</th>\n      <td>1</td>\n      <td>M</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>25</th>\n      <td>1</td>\n      <td>N</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>26</th>\n      <td>1</td>\n      <td>O</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>27</th>\n      <td>1</td>\n      <td>P</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>28</th>\n      <td>1</td>\n      <td>Q</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>29</th>\n      <td>1</td>\n      <td>R</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>30</th>\n      <td>1</td>\n      <td>S</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>31</th>\n      <td>1</td>\n      <td>T</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>32</th>\n      <td>1</td>\n      <td>A</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>33</th>\n      <td>1</td>\n      <td>B</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>34</th>\n      <td>1</td>\n      <td>C</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>35</th>\n      <td>1</td>\n      <td>A</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>36</th>\n      <td>1</td>\n      <td>B</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>37</th>\n      <td>1</td>\n      <td>C</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>38</th>\n      <td>1</td>\n      <td>D</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>39</th>\n      <td>1</td>\n      <td>E</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>40</th>\n      <td>1</td>\n      <td>F</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>41</th>\n      <td>1</td>\n      <td>G</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n    <tr>\n      <th>42</th>\n      <td>1</td>\n      <td>H</td>\n      <td>[\"1\"]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>[\"x,y,z\"]</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "execution_count": 10
    }
   ],
   "source": [
    "concat(res_dfs, sort=False, ignore_index=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "pdb_2a01 = PDB('2a01')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "    pdb_id struct_asym_id entity_id  residue_number residue_name  \\\n0     2a01              A         1               1          ASP   \n1     2a01              A         1               2          GLU   \n2     2a01              A         1               3          PRO   \n3     2a01              A         1               4          PRO   \n4     2a01              A         1               5          GLN   \n..     ...            ...       ...             ...          ...   \n724   2a01              C         1             239          LYS   \n725   2a01              C         1             240          LEU   \n726   2a01              C         1             241          ASN   \n727   2a01              C         1             242          THR   \n728   2a01              C         1             243          GLN   \n\n     authore_residue_number chain_id author_insertion_code  \n0                         1        A                        \n1                         2        A                        \n2                         3        A                        \n3                         4        A                        \n4                         5        A                        \n..                      ...      ...                   ...  \n724                     239        C                        \n725                     240        C                        \n726                     241        C                        \n727                     242        C                        \n728                     243        C                        \n\n[729 rows x 8 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>pdb_id</th>\n      <th>struct_asym_id</th>\n      <th>entity_id</th>\n      <th>residue_number</th>\n      <th>residue_name</th>\n      <th>authore_residue_number</th>\n      <th>chain_id</th>\n      <th>author_insertion_code</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2a01</td>\n      <td>A</td>\n      <td>1</td>\n      <td>1</td>\n      <td>ASP</td>\n      <td>1</td>\n      <td>A</td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2a01</td>\n      <td>A</td>\n      <td>1</td>\n      <td>2</td>\n      <td>GLU</td>\n      <td>2</td>\n      <td>A</td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>2a01</td>\n      <td>A</td>\n      <td>1</td>\n      <td>3</td>\n      <td>PRO</td>\n      <td>3</td>\n      <td>A</td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>2a01</td>\n      <td>A</td>\n      <td>1</td>\n      <td>4</td>\n      <td>PRO</td>\n      <td>4</td>\n      <td>A</td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2a01</td>\n      <td>A</td>\n      <td>1</td>\n      <td>5</td>\n      <td>GLN</td>\n      <td>5</td>\n      <td>A</td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>724</th>\n      <td>2a01</td>\n      <td>C</td>\n      <td>1</td>\n      <td>239</td>\n      <td>LYS</td>\n      <td>239</td>\n      <td>C</td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>725</th>\n      <td>2a01</td>\n      <td>C</td>\n      <td>1</td>\n      <td>240</td>\n      <td>LEU</td>\n      <td>240</td>\n      <td>C</td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>726</th>\n      <td>2a01</td>\n      <td>C</td>\n      <td>1</td>\n      <td>241</td>\n      <td>ASN</td>\n      <td>241</td>\n      <td>C</td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>727</th>\n      <td>2a01</td>\n      <td>C</td>\n      <td>1</td>\n      <td>242</td>\n      <td>THR</td>\n      <td>242</td>\n      <td>C</td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>728</th>\n      <td>2a01</td>\n      <td>C</td>\n      <td>1</td>\n      <td>243</td>\n      <td>GLN</td>\n      <td>243</td>\n      <td>C</td>\n      <td></td>\n    </tr>\n  </tbody>\n</table>\n<p>729 rows × 8 columns</p>\n</div>"
     },
     "metadata": {},
     "execution_count": 12
    }
   ],
   "source": [
    "pdb_2a01.fetch_from_PDBArchive('obsolete/mmCIF/', PDB.cif2residue_listing).result()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stderr",
     "text": "2020-09-20 19:46:39,407 ProcessPDBe WARNING 404/405 for: {'url': 'https://www.ebi.ac.uk/pdbe/api/pdb/entry/summary/2a01'}\n"
    },
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "{'title': 'Crystal Structure of Lipid-free Human Apolipoprotein A-I',\n 'status_code': 'OBS',\n 'since': '20060221',\n 'experimental_method_class': 'x-ray',\n 'entry_authors': 'Ajees, A.A., Anantharamaiah, G.M., Mishra, V.K., Hussain, M.M., Murthy, K.H.M.',\n 'obsoletes': [],\n 'superceded_by': [None],\n 'experimental_method': 'X-RAY DIFFRACTION'}"
     },
     "metadata": {},
     "execution_count": 13
    }
   ],
   "source": [
    "pdb_2a01.status"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ]
}